//
//  ContextMenuDemo.swift
//  SwiftUIDemo
//
//  Created by Tilt Wang on 2025/6/30.
//

import SwiftUI

struct ContextMenuDemo: View {
    
    @State var backgroundColor: Color = .gray
    
    var body: some View {
        VStack(alignment: .leading, spacing: 10.0) {
            Image(systemName: "house.fill")
                .font(.title)
            Text("Hello, World!")
                .font(.headline)
            Text("Hello, World!")
                .font(.subheadline)
        }
        .foregroundColor(.white)
        .padding(30)
        .background(backgroundColor).cornerRadius(20)
        .contextMenu {
            Button {
                backgroundColor = .custom
            } label: {
                Label("Share post", systemImage: "flame.fill")
            }
            
            Button {
                backgroundColor = .brown
            } label: {
                Text("Report post")
            }
            
            Button {
                backgroundColor = .red
            } label: {
                HStack {
                    Text("Like post")
                    Image(systemName: "heart.fill")
                }
            }

        }
    }
}

#Preview {
    ContextMenuDemo()
}
